/*
*********************************************************************************************************
*
*	???? : SPI????FLASH ????
*	???? : bsp_spi_flash.h
*	?    ? : V1.0
*	?    ? : ???
*
*	Copyright (C), 2013-2014, ????? www.armfly.com
*
*********************************************************************************************************
*/

#ifndef _BSP_SPI_FLASH_H
#define _BSP_SPI_FLASH_H

#include "mcc_generated_files/mcc.h"
#include "mian.h"

#define SF_MAX_PAGE_SIZE	(4 * 1024)

/* ????Flash ID */

#define	SST25VF016B_ID  0xBF2541
#define		MX25L1606E_ID    0xC22015
#define		W25Q64_ID       0xEF4017
#define		W25Q128_ID       0xEF4018
#define	    FM25Q04         0xA14013

typedef struct
{
	uint32_t ChipID;		/* ??ID */
	char ChipName[16];		/* ?????????????? */
	uint32_t TotalSize;		/* ??? */
	uint16_t PageSize;		/* ???? */
}SFLASH_T;

void bsp_InitSFlash(void);
uint32_t sf_ReadID(void);
void sf_EraseChip(void);
void sf_EraseSector(uint32_t _uiSectorAddr);
void sf_PageWrite(uint8_t * _pBuf, uint32_t _uiWriteAddr, uint16_t _usSize);
uint8_t sf_WriteBuffer(uint8_t* _pBuf, uint32_t _uiWriteAddr, uint16_t _usWriteSize);
void sf_ReadBuffer(uint8_t * _pBuf, uint32_t _uiReadAddr, uint32_t _uiSize);
void sf_ReadInfo(void);

extern SFLASH_T g_tSF;

#endif

/***************************** ????? www.armfly.com (END OF FILE) *********************************/